简化命令输入，先 sudo -i 切换到root用户权限

1、安装配置自带 tomcat：
查看tomcat版本（8、9、10）
apt search tomcat 

安装和系统匹配版本
apt install tomcat10*

查看是否监听8080端口
ss -natl

启动关闭 tomcat：
systemctl restart tomcat10
systemctl stop tomcat10


2、下载运行 tomcat（以 tomcat9 举例）：
访问 ：https://tomcat.apache.org/
下载 tomcat9：
wget https://dlcdn.apache.org/tomcat/tomcat-9/v9.0.89/bin/apache-tomcat-9.0.104.tar.gz

解压tomcat9：
tar zxvf apache-tomcat-9.0.89.tar.gz

启动关闭 tomcat：
./apache-tomcat-9.0.89/bin/startup.sh
./apache-tomcat-9.0.89/bin/shutdown.sh

3、配置登录管理（或者直接发布应用在 webapps 目录）
修改 tomcat 目录里面的 conf 子目录 tomcat-users.xml 文件
  <user username="admin" password="pass" roles="manager-gui"/>
  <user username="robot" password="pass" roles="manager-script"/>

打开修改manager.xml，若没有则新建
./apache-tomcat-9.0.89/conf/Catalina/localhost/manager.xml
添加如下内容：
<Context privileged="true" antiResourceLocking="false"   
         docBase="${catalina.home}/webapps/manager">  
             <Valve className="org.apache.catalina.valves.RemoteAddrValve" allow="^.*$" />  
</Context>

重启 tomcat，即可浏览器管理应用
